|
|
|
|
|
|
|
Figure 16.6
For a perfect reflector, light arrives and leaves, making
the same angle with the surface normal. |
|
|
|
|
|
|
|
|
The value ks is a new specular reflection constant that depends on the particular surface. Unlike with other lighting model constants, there is only one specular constant rather than one each for the surface's red, green, and blue components. Specular reflection brightens each color component in equal amounts, so you only need one constant. |
|
|
|
|
|
|
|
|
Suppose V is the unit vector from the point on the surface to the viewpoint, and R is the unit vector pointing in the direction of the angle of reflection as shown in Figure 16.8. Then you can rewrite Cosn(f) as: |
|
|
|
 |
|
|
|
|
Cosn (f) = (R V)n |
|
|
|
|
|
|
|
|
Substituting this value into the previous equation gives: |
|
|
|
 |
|
|
|
|
I = Ia * ka +
Ii * (kd * (L N) + ks * (R V)n) *
(rmin + kdist) / (r + kdist) |
|
|
|
|
|
|
|
|
The vectors L, N, and V are easy to calculate, but R is not. Fortunately, you can find the vector R using a little vector algebra. Figure 16.9 shows the unit vector L pointing from the surface toward the light source, and the surface's unit normal vector N. The vector B is chosen to be perpendicular to N. The vector A is the projection of the vector L along the vector N. |
|
|
|
|
|
|
|
|
In terms of vector addition, A = L + B. In other words, you can get the components of vector A by adding the corresponding components of vectors L and B. For example, |
|
|
|
|
|
|
|
|
Figure 16.7
For an imperfect reflector, light leaves in directions close
to the mirror direction. |
|
|
|
|
|